Imports System
Imports System.Collections.Generic

Partial Public Class Helper
    ''' <summary>
    ''' Generic TryParse Method
    ''' ideal for teting an Interface
    ''' </summary>
    ''' <typeparam name="T">User defined generic type</typeparam>
    ''' <param name="Arg">Original object</param>
    ''' <param name="result">Output original object reference as user defined generic type.</param>
    ''' <returns>Determines if Original object is the user defined generic type specified.</returns>
    Public Function TryParse(Of T)(ByVal Arg As [Object], ByRef result As T) As [Boolean]
        Dim isType As [Boolean] = (TypeOf Arg Is T)
        result = DirectCast((If((isType), Arg, Nothing)), T)
        Return isType
    End Function
End Class
